// action type
// 添加待办事项
export const ADD_TODO = 'ADD_TODO'
// 添加待办事项异步
export const ADD_TODO_ASYNC = 'ADD_TODO_ASYNC'
// 删除待办项
export const DEL_TODO = 'DEL_TODO'
// 更改待办项的完成状态
export const TOGGLE_COMPLETE = 'TOGGLE_COMPLETE'
// 更改显示待办项的状态
export const CHANGE_DISPLAY = 'CHANGE_DISPLAY'

// action Creator
const actions = {
    // 添加一条待办，payload参数就是一条待办的数据
    addTodo: payload => ({ type: ADD_TODO, payload }),
    addTodoSync: () => ({ type: ADD_TODO_ASYNC }),
    // 删除待办项数据，payload为id
    delTodo: payload => ({ type: DEL_TODO, payload }),
    // 更改完成状态，此处payload传id
    toggleComplete: payload => ({ type: TOGGLE_COMPLETE, payload }),
    // 更改显示待办项的状态，payload为以下3个值（all,uncompleted,completed）
    changeDisplay: payload => ({ type: CHANGE_DISPLAY, payload })
}

export default actions
